<?php

namespace app\admin\app\model;

use plugin\admin\app\model\Base;

/**
 * @property integer $id 主键(主键)
 * @property string $created_at 创建时间
 * @property string $updated_at 更新时间
 * @property string $filename 文件名
 * @property string $path 视频
 * @property integer $status 状态
 * @property integer $admin_id 管理员id
 * @property integer $category_id 分类
 */
class Video extends Base
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'wa_video';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';

    protected $guarded = ['id'];

    public function getPathAttribute($value)
    {
        return $value && strpos($value, 'http') === false ? config('qiniu.domain') . $value : $value;
    }

    protected static function booted()
    {
//        static::deleting(function ($model) {
//            $qiniu = new Qiniu();
//            $qiniu->delete(str_replace(config('qiniu.domain'), '', $model->path));
//        });
    }
}
